//
//  TimeModel.swift
//  WeiBo test
//
//  Created by Aquarius_wing on 16/5/11.
//  Copyright © 2016年 Wing. All rights reserved.
//

import UIKit

class TimeModel: NSObject {
    var year:String?
    var month:String?
    var day:String?
    var hour:String?
    var minute:String?
    var second:String?
    
    
    init(date:NSDate) {
        super.init()
        self.date=date
    }
    
    override var description: String{
        let keys=["year","month","day","hour","minute","second"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
    
    var date:NSDate?{
        didSet{
            let timeFm=NSDateFormatter()
            //yyyy-MM-dd HH:mm:ss 时间格式
            timeFm.dateFormat="yyyy"
            year=timeFm.stringFromDate(date!)
            
            timeFm.dateFormat="MM"
            month=timeFm.stringFromDate(date!)
            
            timeFm.dateFormat="dd"
            day=timeFm.stringFromDate(date!)
            
            timeFm.dateFormat="HH"
            hour=timeFm.stringFromDate(date!)
            
            timeFm.dateFormat="mm"
            minute=timeFm.stringFromDate(date!)
            
            timeFm.dateFormat="ss"
            second=timeFm.stringFromDate(date!)
        }
    }
}
